//
// Created by Bili_TianX_Computer on 2021/7/8.
//

#ifndef SUPERMARKETMANAGESYSTEM_PRODUCT_H
#define SUPERMARKETMANAGESYSTEM_PRODUCT_H

#include <QString>
#include <QJsonObject>

class Product
{
public:


    QString name;
    double purchasePrice;
    double sellingPrice;
    unsigned short stock;
    QString unit;

    Product(QJsonObject obj);

    Product(const QString &name, double purchasePrice, double sellingPrice, unsigned int stock, const QString &unit);

    double getProfit() const
    { return sellingPrice - purchasePrice; }

    double getGrossProfitMargin() const
    { return getProfit() / purchasePrice; }

    QJsonObject toJsonObject();

    bool operator==(const Product &rhs) const;

    bool operator!=(const Product &rhs) const;
};


#endif //SUPERMARKETMANAGESYSTEM_PRODUCT_H
